import java.util.Scanner;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/5/11
 * Time:16:36
 **/
public class Main2 {

    public static void main1(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String str1 = sc.nextLine();
            String str2 = sc.nextLine();
            System.out.println(getMaxLen(str1, str2));
        }
    }

    /**
     * 每日一题-公共子串计算
     *
     * @param str1
     * @param str2
     * @return
     */
    public static int getMaxLen(String str1, String str2) {
        char[] arr1 = str1.toCharArray();
        char[] arr2 = str2.toCharArray();
        int len1 = arr1.length;
        int len2 = arr2.length;
        int[][] maxSubLen = new int[len1 + 1][len2 + 1];
        int maxLen = 0;
        for (int i = 1; i < len1; i++) {
            for (int j = 1; j < len2; j++) {
                if (arr1[i - 1] == arr2[j - 1]) {
                    //F[i,j] = F[i-1,j-1]+1
                    maxSubLen[i][j] = maxSubLen[i - 1][j - 1] + 1;
                    if (maxLen < maxSubLen[i][j]) {//查看是否需要更新最大值
                        maxLen = maxSubLen[i][j];
                    }
                }
            }
        }
        return maxLen;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String str1 = sc.nextLine();
            String str2 = sc.nextLine();
            char[] arr1 = str1.toCharArray();
            char[] arr2 = str2.toCharArray();
            int len1 = arr1.length;
            int len2 = arr2.length;
            int[][] maxSubLen = new int[len1 + 1][len2 + 1];
            int maxLen = 0;
            for (int i = 1; i < len1; i++) {
                for (int j = 1; j < len2; j++) {
                    if (arr1[i - 1] == arr2[j - 1]) {
                        //F[i,j] = F[i-1,j-1]+1
                        maxSubLen[i][j] = maxSubLen[i - 1][j - 1] + 1;
                        if (maxLen < maxSubLen[i][j]) {//查看是否需要更新最大值
                            maxLen = maxSubLen[i][j];
                        }
                    }
                }
            }
            System.out.println(maxLen);
        }
    }
}
